#include "PlayerManager.h"

PlayerManager::PlayerManager (vector< Color3f > colorCollect)
{
  _colorCollect = colorCollect;
  // Create a player represents no_player
  _players.push_back (Player (0, _colorCollect[0]));
  _curPlayerIndex = 0;
}

bool PlayerManager::add_player (int playerIndex)
{
  // Check whether the index has been chosen
  for (int i = 0; i < _players.size (); ++i)
    if (playerIndex == _players[i].id)
      return false;
  _players.push_back (Player (playerIndex, _colorCollect[playerIndex]));
  return true;
}

void PlayerManager::turn_next ()
{
  if (_players.size () == 1)
    return;
  ++_curPlayerIndex;
  if (_curPlayerIndex == _players.size ())
    _curPlayerIndex = 1;
}

Player PlayerManager::cur_player () const
{
  return _players[_curPlayerIndex];
}